import React from 'react'
import { FormItem } from '../../../components/VForm/interface'
import VForm from '../../../components/VForm'
import { Button, Form, Select, message } from 'antd'
import { SumbitCardInfo } from './service'




export default function FuelCardInfo() {
  const [form] = Form.useForm()

  const formItems: FormItem[] = [
    {
      name: 'card_id',
      label: '油卡号',
      required: true,
      // item:
      rule: { len: 4, message: '长度为4位' },
      type: 'input'
    },
    {
      name: 'card_balance',
      label: '余额',
      required: true,
      type: 'input'
    },
    {
      name: 'driver_id',
      label: '持有人工号',
      required: true,
      type: 'input'
    }

   
  ]
  const handleSumbit = async () => {
    const values=form.getFieldsValue();
    /** 接口 */
    await SumbitCardInfo(values).then(res=>{
      if(res.data.result==="SUCCESS"){
        message.success('提交成功');
      }
    })
  }
  return (
    <div className="Vform-container">
      <div className="Vform">
        <VForm formItems={formItems} form={form} />
      </div>

      <div className="sumbit-btn">
        <Button type="primary" onClick={handleSumbit}>
          提交
        </Button>
      </div>
    </div>
  )
}
